//============================================================================
//	警告: 这个文件是使用2009-8-28 17:56:54建立的IBatisNetGen.DaoImpl.cst生成的.
//				重新生成时,原先手动做的修改将会丢失.
//============================================================================
using System;
using System.Collections.Generic;
using System.Text;
using IBatisNet.DataMapper;
using Bino.ExamOnline.Components.Entitys;
using Bino.ExamOnline.Components.Interface;
using Bino.Common.TextLib;

namespace Bino.ExamOnline.DataProvider 
{	
    /// <summary>实现<see cref="IStudentDao"/>接口.</summary>
    public class StudentDataProvider : DataProviderBase, IStudentDao 
	{
		/// <summary>实现 <see cref="IStudentDao.GetStudentsCount"/></summary>
		public int GetStudentsCount() {
			string statementId = "Student.GetStudentsCount";
			int result = ExecuteQueryForObject<int>(statementId, null);
			return result;
		}

		/// <summary>实现 <see cref="IStudentDao.GetStudent"/></summary>
		public Student GetStudent(Int32 iD) 
		{
			string statementId = "Student.GetStudent";
			Student result = ExecuteQueryForObject<Student>(statementId, iD);
			return result;
		}


		/// <summary>实现 <see cref="IStudentDao.GetAllStudents"/></summary>
		public IList<Student> GetAllStudents() 
		{
			string statementId = "Student.GetAllStudents";
			IList<Student> results = ExecuteQueryForList<Student>(statementId, null);
			return results;
		}

		/// <summary>实现 <see cref="IStudentDao.GetAllStudentsWithOutLob"/></summary>
		public IList<Student> GetAllStudentsWithOutLob()
		{
			string statementId = "Student.GetAllStudentsWithOutLob";
			IList<Student> results = ExecuteQueryForList<Student>(statementId, null);
			return results;
		}
	
		/// <summary>实现 <see cref="IStudentDao.CreateStudent"/></summary>
		public void CreateStudent(Student obj)
		{
			if (obj == null) 
				return;
			string statementId = "Student.CreateStudent";
			ExecuteInsert(statementId, obj);
		}

		/// <summary>实现 <see cref="IStudentDao.UpdateStudent"/></summary>
		public void UpdateStudent(Student obj) 
		{
            UpdateStudent(obj, false);
		}
        /// <summary>实现 <see cref="IStudentDao.UpdateStudent"/></summary>
        public void UpdateStudent(Student obj,bool isUpdatePassword)
        {
            if (obj == null)
                return;
            string statementId;
            if(isUpdatePassword)
                statementId = "Student.UpdateStudent";//同时更新password
            else
                statementId = "Student.UpdateStudentNoPassword";//不更新password
            ExecuteUpdate(statementId, obj);
        }

		/// <summary>实现 <see cref="IStudentDao.DeleteStudent"/></summary>
		public void DeleteStudent(Student obj) 
		{
			if (obj == null)
				return;
			string statementId = "Student.DeleteStudent";
			ExecuteDelete(statementId, obj);
		}

		/// <summary>实现 <see cref="IStudentDao.DeleteStudentByID"/></summary>
		public int DeleteStudentByID(Int32 iD) 
		{
			string statementId = "Student.DeleteStudentByID";
            int result = StringHelper.SafeInt(ExecuteDelete(statementId, iD).ToString(), -1);
			return result;
		}		

		/// <summary>实现 <see cref="IStudentDao.ReloadStudent"/></summary>
		public void ReloadStudent(Student obj) 
		{
			if (obj == null) 
				return;
			string statementId = "Student.GetStudent";
			ExecuteQueryForObject<Student>(statementId, obj, obj);
		}

        /// <summary>
        /// 学生登录 1登录成功 0 登录失败
        /// </summary>        
        public int LoginStudent(String UserName, String UserPassword)
        {
            string statementId = "Student.LoginStudent";
            Student obj = new Student();
            obj.UserName = UserName;
            obj.UserPassword = UserPassword;
            int result = ExecuteQueryForObject<int>(statementId, obj);
            return result;
        }

	}
}
